<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head th:include="admin/head :: head" th:with="title=等级订单编辑">
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form" action="" lay-filter="formfilter">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>用户id:</label>
                    <div class="layui-input-block">
                            <input type="text" id="userId" name="userId" lay-verify="required|userId" autocomplete="off"  class="layui-input" th:value="${ m.userId}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>价格:</label>
                    <div class="layui-input-block">
                            <input type="text" id="price" name="price" lay-verify="required|price" autocomplete="off"  class="layui-input" th:value="${ m.price}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>等级ID:</label>
                    <div class="layui-input-block">
                            <input type="text" id="gradeId" name="gradeId" lay-verify="required|gradeId" autocomplete="off"  class="layui-input" th:value="${ m.gradeId}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>等级名称:</label>
                    <div class="layui-input-block">
                            <input type="text" id="gradeName" name="gradeName" lay-verify="required|gradeName" autocomplete="off"  class="layui-input" th:value="${ m.gradeName}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>支付状态（0待支付，已支付）:</label>
                    <div class="layui-input-block">
                            <input type="text" id="payStatus" name="payStatus" lay-verify="required|payStatus" autocomplete="off"  class="layui-input" th:value="${ m.payStatus}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>支付时间:</label>
                    <div class="layui-input-block">
                            <input type="text" id="payTime" name="payTime" lay-verify="required|payTime" autocomplete="off"  class="layui-input" th:value="${ m.payTime}">
                    </div>
                </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input type="hidden" name="id" th:value="${ m.id}">
                    <button class="layui-btn" lay-submit="" lay-filter="formSubmit">立即提交</button>
                </div>
            </div>
        </form>
    </div>
</div>

<script>
    layui.use(['laydate', 'layer', 'jquery','liuQi'], function () {
            var form = layui.form,
                liuQi = layui.liuQi,
                laydate = layui.laydate;

            //日期
            form.render();

            //自定义验证规则
            form.verify({
                //radio验证
                otherReq: function(value,item){
                    var $ = layui.$;
                    var verifyName=$(item).attr('name')
                            , verifyType=$(item).attr('type')
                            ,formElem=$(item).parents('.layui-form')//获取当前所在的form元素，如果存在的话
                            ,verifyElem=formElem.find('input[name='+verifyName+']')//获取需要校验的元素
                            ,isTrue= verifyElem.is(':checked')//是否命中校验
                            ,focusElem = verifyElem.next().find('i.layui-icon');//焦点元素
                    if(!isTrue || !value){
                        //定位焦点
                        focusElem.css(verifyType=='radio'?{"color":"#FF5722"}:{"border-color":"#FF5722"});
                        //对非输入框设置焦点
                        focusElem.first().attr("tabIndex","1").css("outline","0").blur(function() {
                            focusElem.css(verifyType=='radio'?{"color":""}:{"border-color":""});
                        }).focus();
                        return '必填项不能为空';
                    }
                },
                userId: function (value) {
                },
                price: function (value) {
                },
                gradeId: function (value) {
                },
                gradeName: function (value) {
                },
                payStatus: function (value) {
                },
                payTime: function (value) {
                },
            })
        //监听提交
            form.on('submit(formSubmit)', function (data) {
                data=data.field;
                liuQi.ajax("/admin/miningMemberOrder/update",data,
                        function (data) {
                            //关闭
                            parent.layer.msg(data.msg);
                            parent.layui.table.reload('currentTableId');
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        }
                );
                return false;
            });
        });
</script>

</body>
</html>